@extends('layouts.tankuang')

@section('content')
    <form name="add_form" id="add_form" action="{{url('admin/units/add_faren',$id)}}" method="post" enctype="multipart/form-data">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div id="frdj">
            <h2 class="text-center mg_b36 mg_t25" style="font-weight: bold;">上传{{getValue($id,'baoan_cailiao','up_id','name')}}</h2>
            <table class="table-form table-border w mg-auto">
                <tr>
                    <td>
                        <input type="file" name="pic" class="easyui-validatebox" data-options="required:true,missingMessage:'上传文件不能为空',validateOnCreate:false,validateOnBlur:true">
                    </td>
                </tr>
            </table>

            <div class="w wbt mg_t25 text-center">
                <button id="go" type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-save'">确定</button>
                <button type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-no'" onclick="$('#shangchuan').window('close')">关闭</button>
            </div>
        </div>
    </form>
    <script>
        $('#go').click(function (){
        	if(!$("#add_form").form('validate')){
			return false;
			}
            var formData = new FormData($("#add_form")[0]);
            $.ajax({
                type: "POST",
                url: "{{url('admin/baoan/add_cailiao',[$id,$uid])}}",
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function(data) {
                    if(data.status == 1){
                        $.messager.alert('信息提示',data.msg,'info');
                        $('#shangchuan').dialog('close');
                        $('.pagination-load').click();
                    }else{
                        $.messager.alert('信息提示',data.msg,'info');
                    }
                }
            });
        });
    </script>
@stop